<include file="Public/header"/>
<div class="x-body">
    <form class="layui-form" action="{:U('Rule/role_modi_handle')}" method="post">

        <div class="layui-form-item">
            <label for="desc" class="layui-form-label">
                <span class="x-red">*</span>角色名称：
            </label>
            <div class="layui-input-inline" style="width:80%;">
                <input type="text" id="title" name="title" required  autocomplete="off" value="{$rs.title}" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">

                 <label class="layui-form-label"><span class="x-red">*</span>状态：</label>
                 <div class="layui-input-inline" style="width:80%;">
                     <select lay-verify="required" name="status" id="status">
                         <option>
                         </option>
                         <optgroup label="请选择">
                             <option value="1" <if condition="$rs.status eq 1"> selected='' </if> >启用</option>
                             <option value="2" <if condition="$rs.status eq 2"> selected='' </if> >停用</option>
                         </optgroup>
                     </select><span id="statusa"></span>
                 </div>

        </div>
	      <div class="layui-form-item layui-form-text">
	          <label class="layui-form-label">
	              拥有权限
	          </label>
	          <table  class="layui-table layui-input-block">
	              <tbody>
					<foreach name="info" item="v">
	                  <tr>
	                      <td class="a1"  style="width:120px;">
	                          <input name="nid[]" class="father" lay-filter="allChoose" lay-skin="primary" type="checkbox" value="{$v.id}"  <in name="v.id" value="$rs.rules">checked</in> title="{$v.title}" >
	                      </td>
	                      <td >
	                          <div class="layui-input-block" style="margin-left:20px;">
	                          	  <foreach name="v.sub" item="s">
	                              	 <input name="nid[]"   lay-filter="singleChoose" lay-skin="primary" type="checkbox" value="{$s.id}"  <in name="s.id" value="$rs.rules">checked</in> title="{$s.title}" data="min">
	                              	 <foreach name="s.sub" item="val">
	                              	 	<input name="nid[]"  class="children" lay-filter="singleChoose" lay-skin="primary" type="checkbox" value="{$val.id}"  <in name="val.id" value="$rs.rules">checked</in> title="{$val.title}" data="min">
                                	 </foreach>
	                              </foreach>
	                          </div>
	                      </td>
	                  </tr>
	                </foreach>
	              </tbody>
	          </table>
	      </div>

        <div class="layui-form-item">
        <input type="hidden" name="id" id="id" value="{$rs.id}">
            <label for="L_repass" class="layui-form-label">
            </label>
            <button  class="layui-btn" lay-filter="submit" lay-submit="submit">保存</button>
        </div>
    </form>
</div>
<script>


    layui.use(['form'], function() {
        $ = layui.jquery;
        form.on('checkbox(allChoose)', function(data){
            var child = $(data.elem).parents('tr').find('input[type="checkbox"]');
            console.log(child);
            child.each(function(index, item){
                item.checked = data.elem.checked;
            });
            form.render('checkbox');
        });
        form.on('checkbox(singleChoose)', function(data){
            var child = $(data.elem).parents('tr').children(".a1").find('input[type="checkbox"]');
            child.each(function(index, item){
                if(data.elem.checked){
                    item.checked = data.elem.checked;
                }
            });
            form.render('checkbox');
        });
    })
</script>
<include file="Public/footer"/>